<?php 

class Lobby extends Obj {
	private static $PAGE = 10;
	private $games;

	public function Lobby() {
		parent::__construct();
		$this->games = array();
	}

	public function getTables($start) {
		$ret = array();
		for($ix = $start;$ix<($start+Lobby::$PAGE);$ix++) {
			if(isset($this->games[$ix])) {
				$id = $this->games[$ix];
				$gm = DB::load($id);
				array_push($ret, $gm);
			}
		}
		return $ret;
	}

	public function addGame($type, $names) {
		switch($type){
			case "TTT":
			foreach($names as $k => $v){
				$gm = new Game($v);
				$ttt = new TTT();
				DB::save($ttt);
				$gm->table = $ttt->id;
				DB::save($gm);
				array_push($this->games, $gm->id);
			}
			break;
		}

	}

}



?>